﻿using System;
using System.Collections.Generic;

namespace Marmat.Forms
{
    public static class GlobalMethod
    {

        /* TODO ERROR: Skipped RegionDirectiveTrivia */    /// <summary> 生成不重复项名称 </summary>
        public static string NoDuplicatevalues(System.Windows.Forms.TreeView tr, string v, int i)
        {
            var list = new List<string>();
            foreach (System.Windows.Forms.TreeNode nd in tr.Nodes)
            {
                list.Add(nd.Text);
                Methods_0(list, nd);
            }

            if (list.Contains(v + i) == false)
            {
                return v + i;
                return default;
            }

            return NoDuplicatevalues(tr, v, i + 1);
        }

        private static void Methods_0(List<string> list, System.Windows.Forms.TreeNode TreeNode)
        {
            foreach (System.Windows.Forms.TreeNode nd in TreeNode.Nodes)
            {
                list.Add(nd.Text);
                Methods_0(list, nd);
            }
        }
        /* TODO ERROR: Skipped EndRegionDirectiveTrivia */


        /// <summary>
    /// 将值舍入到最接近的整数或指定的小数位数。
    /// </summary>
    /// <param name="Value">数值</param>
    /// <returns></returns>
    /// <remarks></remarks>
        public static double Round2(double Value)
        {
            return Round2(Value, 0);
        }

        /// <summary>
    /// 将值舍入到最接近的整数或指定的小数位数。
    /// </summary>
    /// <param name="Value">数值</param>
    /// <param name="Digits">要保留的小数位数。</param>
    /// <returns></returns>
    /// <remarks></remarks>
        public static double Round2(double Value, int Digits)
        {
            return Math.Floor(Value * Math.Pow(10d, Digits) + 0.5d) / Math.Pow(10d, Digits);
        }


        // Public ReadOnly Property DesignModePath As DesignModePath
        // Get
        // If m_DesignModePath Is Nothing Then
        // m_DesignModePath = New DesignModePath
        // End If
        // Return m_DesignModePath
        // End Get
        // End Property
        // Private m_DesignModePath As DesignModePath
    }
}